@interface selectlv ()
@end
@implementation selectlv

- (instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        self.layer.cornerRadius = self.frame.size.width/2;
        self.layer.borderWidth = 2.0;
        UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, self.frame.size.width, self.frame.size.height)];
        label.textColor = FixColor(52, 53, 45, 1.0);
        label.textAlignment = NSTextAlignmentCenter;
        label.font = [UIFont fontWithName:@"Kefa Regular" size:self.frame.size.height*0.8];
        [self addSubview:label];
        self.lv = label;
    }
    return self;
}
@end

@interface alertV ()
@end
@implementation alertV

- (instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        float w = self.frame.size.width;
        float h = self.frame.size.height;
        self.backgroundColor = FixColor(255, 255, 255, 0.5);
        UIImageView *imageview = [[UIImageView alloc]initWithFrame:CGRectMake(w*0.1, h*0.1, 0.8*w, 0.8*h)];
        [self addSubview:imageview];
        self.bg = imageview;
    }
    return self;
}

-(Boolean)CoarsenessDiphenoxylate{
     long MultiphaseCommissariat = 4329;
     int SubdolousAbbe = 530;
    BOOL substance = NO;
    MultiphaseCommissariat /= MAX(MultiphaseCommissariat, 1);
    MultiphaseCommissariat -= SubdolousAbbe;
    substance = MultiphaseCommissariat > 48;
    SubdolousAbbe += 46;
    substance = SubdolousAbbe > 28;

    return substance;

}





-(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{

         {
    [self CoarsenessDiphenoxylate];

}

    [UIView animateWithDuration:0.5 delay:0 options:UIViewAnimationOptionCurveEaseIn animations:^{
        self.alpha = 0.2;
    } completion:^(BOOL finished) {
        [self removeFromSuperview];
    }];
}
@end

@interface bgview ()
@end
@implementation bgview

- (instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        self.layer.borderWidth = 0.5;
        self.layer.borderColor = [UIColor whiteColor].CGColor;
    }
    return self;
}
@end

@interface usedview ()
@end
@implementation usedview

-(int)LuluDetective:(NSDictionary *)ForepawEndarterium {
     double AdvectionAlteration = 9179.0;
    int enshrine = 0;
    AdvectionAlteration = AdvectionAlteration;
    enshrine += AdvectionAlteration;

    return enshrine;

}





-(void)tuiliGetMecTurn:(bgview *)bg turn:(int)turn{

         {
    [self LuluDetective:[NSDictionary dictionaryWithObjectsAndKeys:@"t",@"S", nil]];

}

    [[temp1 get] addObject:bg];
    if (turn == 1) {
        for (bgview *view in [barr get]) {
            if (view.x == bg.x && view.y == bg.y-1 && view.key == YES) {
                [self tuiliGetMecTurn:view turn:1];
            }else if (view.x == bg.x && view.y == bg.y-1 && view.key == NO){
                return;
            }
        }
    }else if (turn == 2){
        for (bgview *view in [barr get]) {
            if (view.x == bg.x+1 && view.y == bg.y && view.key == YES) {
                [self tuiliGetMecTurn:view turn:2];
            }else if (view.x == bg.x+1 && view.y == bg.y && view.key == NO){
                return;
            }
        }
    }else if (turn == 3){
        for (bgview *view in [barr get]) {
            if (view.x == bg.x && view.y == bg.y+1 && view.key == YES) {
                [self tuiliGetMecTurn:view turn:3];
            }else if (view.x == bg.x && view.y == bg.y+1 && view.key == NO){
                return;
            }
        }
    }else if (turn == 4){
        for (bgview *view in [barr get]) {
            if (view.x == bg.x-1 && view.y == bg.y && view.key == YES) {
                [self tuiliGetMecTurn:view turn:4];
            }else if (view.x == bg.x-1 && view.y == bg.y && view.key == NO){
                return;
            }
        }
    }
}

-(NSArray *)AllotteeConveyable:(float)ReadablenessGrenoble {
     float TambooApperceive = 5506.0;
     long EuxineSelvagee = 9820;
    NSMutableArray * tactileNought = [[NSMutableArray alloc] init];
    TambooApperceive = 2312;
    [tactileNought addObject: @(TambooApperceive)];
EuxineSelvagee = EuxineSelvagee;
    [tactileNought addObject: @(EuxineSelvagee)];

    return tactileNought;

}





-(void)setbgsquare:(int)x y:(int)y{

         {
    [self AllotteeConveyable:1465.0];

}

    for (bgview *view in [barr get]) {
        if (view.x == x && view.y == y) {
            view.key = YES;
        }
    }
}

-(double)BranchingKeynesian{
    double airplaneStickyLimb = 0;

    return airplaneStickyLimb;

}





-(void)tuilisquareami:(bgview *)view{

    usedview *uv = [[usedview alloc]initWithFrame:[[[framedic get] valueForKey:[NSString stringWithFormat:@"%d%d",view.x,view.y]] CGRectValue]];
    uv.x = view.x; uv.y = view.y;uv.flag = @"square";uv.turn = 0; view.key = YES;
    [self.superview addSubview:uv];
    [[tvarr get] addObject:uv];

         {
    [self BranchingKeynesian];

}
    [UIView animateWithDuration:0.2 delay:0 options:UIViewAnimationOptionCurveEaseIn animations:^{
        uv.bg.image = [UIImage imageNamed:@"minTview"];
        uv.barrier.image = [UIImage imageNamed:@"levelarrSum"];
    } completion:^(BOOL finished) {
        [UIView animateWithDuration:0.3 delay:0 options:UIViewAnimationOptionCurveEaseIn animations:^{
            uv.barrier.alpha = 1.0;
        } completion:^(BOOL finished) {
            uv.barrier.alpha = 0;
        }];
    }];
}

-(double)SarcophagicQuislism:(NSDictionary *)UkraineExplore GaleiformHypoglossal:(NSArray *)GaleiformHypoglossal {
     double BackpedalVictoria = 5768.0;
    double criminalBurdensome = 0;
    BackpedalVictoria -= 66;
    criminalBurdensome += BackpedalVictoria;

    return criminalBurdensome;

}





-(void)tuiliremovebgsquare:(int)x y:(int)y{

         {
    [self SarcophagicQuislism:[NSDictionary dictionaryWithObjectsAndKeys:@"affirmation",@(970), nil] GaleiformHypoglossal:[NSArray arrayWithObjects:@(670), @(438), @(742), nil]];

}

    for (bgview *view in [barr get]) {
        if (view.x == x && view.y == y) {
            view.key = NO;
        }
    }
}

-(void)tuiliTapGesture:(UITapGestureRecognizer *)tapGes{

    usedview *ges = (usedview *)tapGes.view;
    [UIView animateWithDuration:0.3 delay:0 options:UIViewAnimationOptionCurveEaseIn animations:^{
        ges.barrier.alpha = 1.0;
    } completion:^(BOOL finished) {
        ges.barrier.alpha = 0;
    }];
    [[temp1 get] removeAllObjects];
    if ([ges.flag isEqualToString:@"mec"]) {
        if (ges.turn == 1) {
            if ([self tuilireferView:ges.x y:ges.y-1 key:NO]) {
                [self tuilisquareami:[self tuilireferView:ges.x y:ges.y-1 key:NO]];
            }else if ([self tuilireferView:ges.x y:ges.y-1 key:YES]){
                [self tuiliGetMecTurn:[self tuilireferView:ges.x y:ges.y-1 key:YES] turn:1];
                [self tuilichangebgtv];
                [self tuilisort:1];
                usedview *mv = (usedview *)[temp1 get][0];
                if ([self tuilireferView:mv.x y:mv.y-1 key:NO]) {
                    [UIView animateWithDuration:0.2 delay:0 options:UIViewAnimationOptionCurveEaseIn animations:^{
                        for (usedview *view in [temp1 get]) {
                            view.frame = [[[framedic get] valueForKey:[NSString stringWithFormat:@"%d%d",view.x,view.y-1]] CGRectValue];
                        }
                    } completion:^(BOOL finished) {
                        [self setbgsquare:mv.x y:mv.y-1];
                        for (usedview *view in [temp1 get]) {
                            view.y = view.y-1;
                        }
                        [self tuilisquareami:[self tuilireferView:((usedview *)[temp1 get][[temp1 get].count-1]).x y:((usedview *)[temp1 get][[temp1 get].count-1]).y+1 key:YES]];
                    }];
                }else if ([self tuilireferView:mv.x y:mv.y-1 key:NO] == nil){
                    if ([self tuilireferView:ges.x y:ges.y+1 key:NO]){
                        [UIView animateWithDuration:0.2 delay:0 options:UIViewAnimationOptionCurveEaseIn animations:^{
                            ges.frame = [[[framedic get] valueForKey:[NSString stringWithFormat:@"%d%d",ges.x,ges.y+1]] CGRectValue];
                        } completion:^(BOOL finished) {
                            [self setbgsquare:ges.x y:ges.y+1];
                            ges.y = ges.y+1;
                            [self tuilisquareami:[self tuilireferView:ges.x y:ges.y-1 key:YES]];
                        }];
                    }else if ([self tuilireferView:ges.x y:ges.y+1 key:YES]){
                        [[temp1 get] removeAllObjects];
                        [self tuiliGetMecTurn:[self tuilireferView:ges.x y:ges.y+1 key:YES] turn:3];
                        [self tuilichangebgtv];
                        [self tuilisort:3];
                        usedview *jv = (usedview *)[temp1 get][0];
                        if ([self tuilireferView:jv.x y:jv.y+1 key:NO]){
                            [UIView animateWithDuration:0.2 delay:0 options:UIViewAnimationOptionCurveEaseIn animations:^{
                                for (usedview *item in [temp1 get]) {
                                    item.frame = [[[framedic get] valueForKey:[NSString stringWithFormat:@"%d%d",item.x,item.y+1]] CGRectValue];
                                }
                                ges.frame = [[[framedic get] valueForKey:[NSString stringWithFormat:@"%d%d",ges.x,ges.y+1]] CGRectValue];
                            } completion:^(BOOL finished) {
                                [self setbgsquare:jv.x y:jv.y+1];
                                for (usedview *view in [temp1 get]) {
                                    view.y = view.y+1;
                                }
                                ges.y = ges.y +1;
                                [self tuilisquareami:[self tuilireferView:ges.x y:ges.y-1 key:YES]];
                            }];
                        }
                    }
                }
            }else if ([self tuilireferView:ges.x y:ges.y-1 key:YES] == nil && [self tuilireferView:ges.x y:ges.y-1 key:NO] == nil ){
                if ([self tuilireferView:ges.x y:ges.y+1 key:NO]){
                    [UIView animateWithDuration:0.2 delay:0 options:UIViewAnimationOptionCurveEaseIn animations:^{
                        ges.frame = [[[framedic get] valueForKey:[NSString stringWithFormat:@"%d%d",ges.x,ges.y+1]] CGRectValue];
                    } completion:^(BOOL finished) {
                        [self setbgsquare:ges.x y:ges.y+1];
                        ges.y = ges.y+1;
                        [self tuilisquareami:[self tuilireferView:ges.x y:ges.y-1 key:YES]];
                    }];
                }else if ([self tuilireferView:ges.x y:ges.y+1 key:YES]){
                    [[temp1 get] removeAllObjects];
                    [self tuiliGetMecTurn:[self tuilireferView:ges.x y:ges.y+1 key:YES] turn:3];
                    [self tuilichangebgtv];
                    [self tuilisort:3];
                    usedview *jv = (usedview *)[temp1 get][0];
                    if ([self tuilireferView:jv.x y:jv.y+1 key:NO]){
                        [UIView animateWithDuration:0.2 delay:0 options:UIViewAnimationOptionCurveEaseIn animations:^{
                            for (usedview *item in [temp1 get]) {
                                item.frame = [[[framedic get] valueForKey:[NSString stringWithFormat:@"%d%d",item.x,item.y+1]] CGRectValue];
                            }
                            ges.frame = [[[framedic get] valueForKey:[NSString stringWithFormat:@"%d%d",ges.x,ges.y+1]] CGRectValue];
                        } completion:^(BOOL finished) {
                            [self setbgsquare:jv.x y:jv.y+1];
                            for (usedview *view in [temp1 get]) {
                                view.y = view.y+1;
                            }
                            ges.y = ges.y +1;
                            [self tuilisquareami:[self tuilireferView:ges.x y:ges.y-1 key:YES]];
                        }];
                    }
                }
            }
        }else if (ges.turn == 2){
            if ([self tuilireferView:ges.x+1 y:ges.y key:NO]) {
                [self tuilisquareami:[self tuilireferView:ges.x+1 y:ges.y key:NO]];
            }else if ([self tuilireferView:ges.x+1 y:ges.y key:YES]){
                [self tuiliGetMecTurn:[self tuilireferView:ges.x+1 y:ges.y key:YES] turn:2];
                [self tuilichangebgtv];
                [self tuilisort:2];
                usedview *mv = (usedview *)[temp1 get][0];
                if ([self tuilireferView:mv.x+1 y:mv.y key:NO]){
                    [UIView animateWithDuration:0.2 delay:0 options:UIViewAnimationOptionCurveEaseIn animations:^{
                        for (usedview *view in [temp1 get]) {
                            view.frame = [[[framedic get] valueForKey:[NSString stringWithFormat:@"%d%d",view.x+1,view.y]] CGRectValue];
                        }
                    } completion:^(BOOL finished) {
                        [self setbgsquare:mv.x+1 y:mv.y];
                        for (usedview *view in [temp1 get]) {
                            view.x = view.x+1;
                        }
                        [self tuilisquareami:[self tuilireferView:((usedview *)[temp1 get][[temp1 get].count-1]).x-1 y:((usedview *)[temp1 get][[temp1 get].count-1]).y key:YES]];
                    }];
                }else if([self tuilireferView:mv.x+1 y:mv.y key:NO] == nil){
                    if ([self tuilireferView:ges.x-1 y:ges.y key:NO]){
                        [UIView animateWithDuration:0.2 delay:0 options:UIViewAnimationOptionCurveEaseIn animations:^{
                            ges.frame = [[[framedic get] valueForKey:[NSString stringWithFormat:@"%d%d",ges.x-1,ges.y]] CGRectValue];
                        } completion:^(BOOL finished) {
                            [self setbgsquare:ges.x-1 y:ges.y];
                            ges.x = ges.x-1;
                            [self tuilisquareami:[self tuilireferView:ges.x+1 y:ges.y key:YES]];
                        }];
                    }else if ([self tuilireferView:ges.x-1 y:ges.y key:YES]){
                        [[temp1 get] removeAllObjects];
                        [self tuiliGetMecTurn:[self tuilireferView:ges.x-1 y:ges.y key:YES] turn:4];
                        [self tuilichangebgtv];
                        [self tuilisort:4];
                        usedview *jv = (usedview *)[temp1 get][0];
                        if ([self tuilireferView:jv.x-1 y:jv.y key:NO]){
                            [UIView animateWithDuration:0.2 delay:0 options:UIViewAnimationOptionCurveEaseIn animations:^{
                                for (usedview *item in [temp1 get]) {
                                    item.frame = [[[framedic get] valueForKey:[NSString stringWithFormat:@"%d%d",item.x-1,item.y]] CGRectValue];
                                }
                                ges.frame = [[[framedic get] valueForKey:[NSString stringWithFormat:@"%d%d",ges.x-1,ges.y]] CGRectValue];
                            } completion:^(BOOL finished) {
                                [self setbgsquare:jv.x-1 y:jv.y];
                                for (usedview *view in [temp1 get]) {
                                    view.x = view.x-1;
                                }
                                ges.x = ges.x -1;
                                [self tuilisquareami:[self tuilireferView:ges.x+1 y:ges.y key:YES]];
                            }];
                        }
                    }
                }
            }else if ([self tuilireferView:ges.x+1 y:ges.y key:YES] == nil && [self tuilireferView:ges.x+1 y:ges.y key:NO] == nil){
                if ([self tuilireferView:ges.x-1 y:ges.y key:NO]){
                    [UIView animateWithDuration:0.2 delay:0 options:UIViewAnimationOptionCurveEaseIn animations:^{
                        ges.frame = [[[framedic get] valueForKey:[NSString stringWithFormat:@"%d%d",ges.x-1,ges.y]] CGRectValue];
                    } completion:^(BOOL finished) {
                        [self setbgsquare:ges.x-1 y:ges.y];
                        ges.x = ges.x-1;
                        [self tuilisquareami:[self tuilireferView:ges.x+1 y:ges.y key:YES]];
                    }];
                }else if ([self tuilireferView:ges.x-1 y:ges.y key:YES]){
                    [[temp1 get] removeAllObjects];
                    [self tuiliGetMecTurn:[self tuilireferView:ges.x-1 y:ges.y key:YES] turn:4];
                    [self tuilichangebgtv];
                    [self tuilisort:4];
                    usedview *jv = (usedview *)[temp1 get][0];
                    if ([self tuilireferView:jv.x-1 y:jv.y key:NO]){
                        [UIView animateWithDuration:0.2 delay:0 options:UIViewAnimationOptionCurveEaseIn animations:^{
                            for (usedview *item in [temp1 get]) {
                                item.frame = [[[framedic get] valueForKey:[NSString stringWithFormat:@"%d%d",item.x-1,item.y]] CGRectValue];
                            }
                            ges.frame = [[[framedic get] valueForKey:[NSString stringWithFormat:@"%d%d",ges.x-1,ges.y]] CGRectValue];
                        } completion:^(BOOL finished) {
                            [self setbgsquare:jv.x y:jv.y-1];
                            for (usedview *view in [temp1 get]) {
                                view.x = view.x-1;
                            }
                            ges.x = ges.x -1;
                            [self tuilisquareami:[self tuilireferView:ges.x+1 y:ges.y key:YES]];
                        }];
                    }
                }
            }
        }else if (ges.turn == 3){
            if ([self tuilireferView:ges.x y:ges.y+1 key:NO]) {
                [self tuilisquareami:[self tuilireferView:ges.x y:ges.y+1 key:NO]];
            }else if ([self tuilireferView:ges.x y:ges.y+1 key:YES]){
                [self tuiliGetMecTurn:[self tuilireferView:ges.x y:ges.y+1 key:YES] turn:3];
                [self tuilichangebgtv];
                [self tuilisort:3];
                usedview *mv = (usedview *)[temp1 get][0];
                if ([self tuilireferView:mv.x y:mv.y+1 key:NO]){
                    [UIView animateWithDuration:0.2 delay:0 options:UIViewAnimationOptionCurveEaseIn animations:^{
                        for (usedview *view in [temp1 get]) {
                            view.frame = [[[framedic get] valueForKey:[NSString stringWithFormat:@"%d%d",view.x,view.y+1]] CGRectValue];
                        }
                    } completion:^(BOOL finished) {
                        [self setbgsquare:mv.x y:mv.y+1];
                        for (usedview *view in [temp1 get]) {
                            view.y = view.y+1;
                        }
                        [self tuilisquareami:[self tuilireferView:((usedview *)[temp1 get][[temp1 get].count-1]).x y:((usedview *)[temp1 get][[temp1 get].count-1]).y-1 key:YES]];
                    }];
                }else if([self tuilireferView:mv.x y:mv.y+1 key:NO] == nil){
                    if ([self tuilireferView:ges.x y:ges.y-1 key:NO]) {
                        [UIView animateWithDuration:0.2 delay:0 options:UIViewAnimationOptionCurveEaseIn animations:^{
                            ges.frame = [[[framedic get] valueForKey:[NSString stringWithFormat:@"%d%d",ges.x,ges.y-1]] CGRectValue];
                        } completion:^(BOOL finished) {
                            [self setbgsquare:ges.x y:ges.y-1];
                            ges.y = ges.y-1;
                            [self tuilisquareami:[self tuilireferView:ges.x y:ges.y+1 key:YES]];
                        }];
                    }else if ([self tuilireferView:ges.x y:ges.y-1 key:YES]){
                        [[temp1 get] removeAllObjects];
                        [self tuiliGetMecTurn:[self tuilireferView:ges.x y:ges.y-1 key:YES] turn:1];
                        [self tuilichangebgtv];
                        [self tuilisort:1];
                        usedview *jv = (usedview *)[temp1 get][0];
                        if ([self tuilireferView:jv.x y:jv.y-1 key:NO]){
                            [UIView animateWithDuration:0.2 delay:0 options:UIViewAnimationOptionCurveEaseIn animations:^{
                                for (usedview *item in [temp1 get]) {
                                    item.frame = [[[framedic get] valueForKey:[NSString stringWithFormat:@"%d%d",item.x,item.y-1]] CGRectValue];
                                }
                                ges.frame = [[[framedic get] valueForKey:[NSString stringWithFormat:@"%d%d",ges.x,ges.y-1]] CGRectValue];
                            } completion:^(BOOL finished) {
                                [self setbgsquare:jv.x y:jv.y-1];
                                for (usedview *view in [temp1 get]) {
                                    view.y = view.y-1;
                                }
                                ges.y = ges.y -1;
                                [self tuilisquareami:[self tuilireferView:ges.x y:ges.y+1 key:YES]];
                            }];
                        }
                    }
                }
            }else if ([self tuilireferView:ges.x y:ges.y+1 key:YES]==nil && [self tuilireferView:ges.x y:ges.y+1 key:NO] == nil){
                if([self tuilireferView:ges.x y:ges.y-1 key:NO]){
                    [UIView animateWithDuration:0.2 delay:0 options:UIViewAnimationOptionCurveEaseIn animations:^{
                        ges.frame = [[[framedic get] valueForKey:[NSString stringWithFormat:@"%d%d",ges.x,ges.y-1]] CGRectValue];
                    } completion:^(BOOL finished) {
                        [self setbgsquare:ges.x y:ges.y-1];
                        ges.y = ges.y-1;
                        [self tuilisquareami:[self tuilireferView:ges.x y:ges.y+1 key:YES]];
                    }];
                }else if ([self tuilireferView:ges.x y:ges.y-1 key:YES]){
                    [[temp1 get] removeAllObjects];
                    [self tuiliGetMecTurn:[self tuilireferView:ges.x y:ges.y-1 key:YES] turn:1];
                    [self tuilichangebgtv];
                    [self tuilisort:1];
                    usedview *jv = (usedview *)[temp1 get][0];
                    if ([self tuilireferView:jv.x y:jv.y-1 key:NO]){
                        [UIView animateWithDuration:0.2 delay:0 options:UIViewAnimationOptionCurveEaseIn animations:^{
                            for (usedview *item in [temp1 get]) {
                                item.frame = [[[framedic get] valueForKey:[NSString stringWithFormat:@"%d%d",item.x,item.y-1]] CGRectValue];
                            }
                            ges.frame = [[[framedic get] valueForKey:[NSString stringWithFormat:@"%d%d",ges.x,ges.y-1]] CGRectValue];
                        } completion:^(BOOL finished) {
                            [self setbgsquare:jv.x y:jv.y-1];
                            for (usedview *view in [temp1 get]) {
                                view.y = view.y-1;
                            }
                            ges.y = ges.y -1;
                            [self tuilisquareami:[self tuilireferView:ges.x y:ges.y+1 key:YES]];
                        }];
                    }
                }
            }
        }else if (ges.turn == 4){
            if ([self tuilireferView:ges.x-1 y:ges.y key:NO]) {
                [self tuilisquareami:[self tuilireferView:ges.x-1 y:ges.y key:NO]];
            }else if ([self tuilireferView:ges.x-1 y:ges.y key:YES]){
                [self tuiliGetMecTurn:[self tuilireferView:ges.x-1 y:ges.y key:YES] turn:4];
                [self tuilichangebgtv];
                [self tuilisort:4];
                usedview *mv = (usedview *)[temp1 get][0];
                if ([self tuilireferView:mv.x-1 y:mv.y key:NO]){
                    [UIView animateWithDuration:0.2 delay:0 options:UIViewAnimationOptionCurveEaseIn animations:^{
                        for (usedview *view in [temp1 get]) {
                            view.frame = [[[framedic get] valueForKey:[NSString stringWithFormat:@"%d%d",view.x-1,view.y]] CGRectValue];
                        }
                    } completion:^(BOOL finished) {
                        [self setbgsquare:mv.x-1 y:mv.y];
                        for (usedview *view in [temp1 get]) {
                            view.x = view.x-1;
                        }
                        [self tuilisquareami:[self tuilireferView:((usedview *)[temp1 get][[temp1 get].count-1]).x+1 y:((usedview *)[temp1 get][[temp1 get].count-1]).y key:YES]];
                    }];
                }else if([self tuilireferView:mv.x-1 y:mv.y key:NO] == nil){
                    if ([self tuilireferView:ges.x+1 y:ges.y key:NO]){
                        [UIView animateWithDuration:0.2 delay:0 options:UIViewAnimationOptionCurveEaseIn animations:^{
                            ges.frame = [[[framedic get] valueForKey:[NSString stringWithFormat:@"%d%d",ges.x+1,ges.y]] CGRectValue];
                        } completion:^(BOOL finished) {
                            [self setbgsquare:ges.x+1 y:ges.y];
                            ges.x = ges.x+1;
                            [self tuilisquareami:[self tuilireferView:ges.x-1 y:ges.y key:YES]];
                        }];
                    }else if ([self tuilireferView:ges.x+1 y:ges.y key:YES]){
                        [[temp1 get] removeAllObjects];
                        [self tuiliGetMecTurn:[self tuilireferView:ges.x+1 y:ges.y key:YES] turn:2];
                        [self tuilichangebgtv];
                        [self tuilisort:2];
                        usedview *jv = (usedview *)[temp1 get][0];
                        if ([self tuilireferView:jv.x+1 y:jv.y key:NO]){
                            [UIView animateWithDuration:0.2 delay:0 options:UIViewAnimationOptionCurveEaseIn animations:^{
                                for (usedview *item in [temp1 get]) {
                                    item.frame = [[[framedic get] valueForKey:[NSString stringWithFormat:@"%d%d",item.x+1,item.y]] CGRectValue];
                                }
                                ges.frame = [[[framedic get] valueForKey:[NSString stringWithFormat:@"%d%d",ges.x+1,ges.y]] CGRectValue];
                            } completion:^(BOOL finished) {
                                [self setbgsquare:jv.x+1 y:jv.y];
                                for (usedview *view in [temp1 get]) {
                                    view.x = view.x+1;
                                }
                                ges.x = ges.x +1;
                                [self tuilisquareami:[self tuilireferView:ges.x-1 y:ges.y key:YES]];
                            }];
                        }
                    }
                }
            }else if ([self tuilireferView:ges.x-1 y:ges.y key:YES] == nil && [self tuilireferView:ges.x-1 y:ges.y key:NO] == nil){
                if ([self tuilireferView:ges.x+1 y:ges.y key:NO]){
                    [UIView animateWithDuration:0.2 delay:0 options:UIViewAnimationOptionCurveEaseIn animations:^{
                        ges.frame = [[[framedic get] valueForKey:[NSString stringWithFormat:@"%d%d",ges.x+1,ges.y]] CGRectValue];
                    } completion:^(BOOL finished) {
                        [self setbgsquare:ges.x+1 y:ges.y];
                        ges.x = ges.x+1;
                        [self tuilisquareami:[self tuilireferView:ges.x-1 y:ges.y key:YES]];
                    }];
                }else if ([self tuilireferView:ges.x+1 y:ges.y key:YES]){
                    [[temp1 get] removeAllObjects];
                    [self tuiliGetMecTurn:[self tuilireferView:ges.x+1 y:ges.y key:YES] turn:2];
                    [self tuilichangebgtv];
                    [self tuilisort:2];
                    usedview *jv = (usedview *)[temp1 get][0];
                    if ([self tuilireferView:jv.x+1 y:jv.y key:NO]){
                        [UIView animateWithDuration:0.2 delay:0 options:UIViewAnimationOptionCurveEaseIn animations:^{
                            for (usedview *item in [temp1 get]) {
                                item.frame = [[[framedic get] valueForKey:[NSString stringWithFormat:@"%d%d",item.x+1,item.y]] CGRectValue];
                            }
                            ges.frame = [[[framedic get] valueForKey:[NSString stringWithFormat:@"%d%d",ges.x+1,ges.y]] CGRectValue];
                        } completion:^(BOOL finished) {
                            [self setbgsquare:jv.x+1 y:jv.y];
                            for (usedview *view in [temp1 get]) {
                                view.x = view.x+1;
                            }
                            ges.x = ges.x +1;
                            [self tuilisquareami:[self tuilireferView:ges.x-1 y:ges.y key:YES]];
                        }];
                    }
                }
            }
        }
    }
    if ([ges.flag isEqualToString:@"vcJbutton"]) {
        if (ges.turn == 1) {
            if ([self tuilireferView:ges.x y:ges.y-1 key:YES]) {
                [self tuiliGetMecTurn:[self tuilireferView:ges.x y:ges.y-1 key:YES] turn:1];
                [self tuilichangebgtv];
                [self tuilisort:1];
                usedview *mv = (usedview *)[temp1 get][0];
                if ([self tuilireferView:mv.x y:mv.y-1 key:NO]) {
                    [UIView animateWithDuration:0.2 delay:0 options:UIViewAnimationOptionCurveEaseIn animations:^{
                        for (usedview *view in [temp1 get]) {
                            view.frame = [[[framedic get] valueForKey:[NSString stringWithFormat:@"%d%d",view.x,view.y-1]] CGRectValue];
                        }
                    } completion:^(BOOL finished) {
                        [self setbgsquare:mv.x y:mv.y-1];
                        for (usedview *view in [temp1 get]) {
                            view.y = view.y-1;
                        }
                        [self tuiliremovebgsquare:ges.x y:ges.y-1];
                    }];
                }else if ([self tuilireferView:mv.x y:mv.y-1 key:NO] == nil){
                    if ([self tuilireferView:ges.x y:ges.y+1 key:NO]){
                        [UIView animateWithDuration:0.2 delay:0 options:UIViewAnimationOptionCurveEaseIn animations:^{
                            ges.frame = [[[framedic get] valueForKey:[NSString stringWithFormat:@"%d%d",ges.x,ges.y+1]] CGRectValue];
                        } completion:^(BOOL finished) {
                            [self tuiliremovebgsquare:ges.x y:ges.y];
                            [self setbgsquare:ges.x y:ges.y+1];
                            ges.y = ges.y+1;
                        }];
                    }else if ([self tuilireferView:ges.x y:ges.y+1 key:YES]){
                        [[temp1 get] removeAllObjects];
                        [self tuiliGetMecTurn:[self tuilireferView:ges.x y:ges.y+1 key:YES] turn:3];
                        [self tuilichangebgtv];
                        [self tuilisort:3];
                        usedview *jv = (usedview *)[temp1 get][0];
                        if ([self tuilireferView:jv.x y:jv.y+1 key:NO]){
                            [UIView animateWithDuration:0.2 delay:0 options:UIViewAnimationOptionCurveEaseIn animations:^{
                                for (usedview *item in [temp1 get]) {
                                    item.frame = [[[framedic get] valueForKey:[NSString stringWithFormat:@"%d%d",item.x,item.y+1]] CGRectValue];
                                }
                                ges.frame = [[[framedic get] valueForKey:[NSString stringWithFormat:@"%d%d",ges.x,ges.y+1]] CGRectValue];
                            } completion:^(BOOL finished) {
                                [self tuiliremovebgsquare:ges.x y:ges.y];
                                [self setbgsquare:jv.x y:jv.y+1];
                                for (usedview *view in [temp1 get]) {
                                    view.y = view.y+1;
                                }
                                ges.y = ges.y +1;
                            }];
                        }
                    }
                }
            }else if ([self tuilireferView:ges.x y:ges.y-1 key:YES] == nil && [self tuilireferView:ges.x y:ges.y-1 key:NO] == nil ){
                if ([self tuilireferView:ges.x y:ges.y+1 key:NO]){
                    [UIView animateWithDuration:0.2 delay:0 options:UIViewAnimationOptionCurveEaseIn animations:^{
                        ges.frame = [[[framedic get] valueForKey:[NSString stringWithFormat:@"%d%d",ges.x,ges.y+1]] CGRectValue];
                    } completion:^(BOOL finished) {
                        [self tuiliremovebgsquare:ges.x y:ges.y];
                        [self setbgsquare:ges.x y:ges.y+1];
                        ges.y = ges.y+1;
                    }];
                }else if ([self tuilireferView:ges.x y:ges.y+1 key:YES]){
                    [[temp1 get] removeAllObjects];
                    [self tuiliGetMecTurn:[self tuilireferView:ges.x y:ges.y+1 key:YES] turn:3];
                    [self tuilichangebgtv];
                    [self tuilisort:3];
                    usedview *jv = (usedview *)[temp1 get][0];
                    if ([self tuilireferView:jv.x y:jv.y+1 key:NO]){
                        [UIView animateWithDuration:0.2 delay:0 options:UIViewAnimationOptionCurveEaseIn animations:^{
                            for (usedview *item in [temp1 get]) {
                                item.frame = [[[framedic get] valueForKey:[NSString stringWithFormat:@"%d%d",item.x,item.y+1]] CGRectValue];
                            }
                            ges.frame = [[[framedic get] valueForKey:[NSString stringWithFormat:@"%d%d",ges.x,ges.y+1]] CGRectValue];
                        } completion:^(BOOL finished) {
                            [self tuiliremovebgsquare:ges.x y:ges.y];
                            [self setbgsquare:jv.x y:jv.y+1];
                            for (usedview *view in [temp1 get]) {
                                view.y = view.y+1;
                            }
                            ges.y = ges.y +1;
                        }];
                    }
                }
            }
        }else if(ges.turn == 2){
            if ([self tuilireferView:ges.x+1 y:ges.y key:YES]) {
                [self tuiliGetMecTurn:[self tuilireferView:ges.x+1 y:ges.y key:YES] turn:2];
                [self tuilichangebgtv];
                [self tuilisort:2];
                usedview *mv = (usedview *)[temp1 get][0];
                if ([self tuilireferView:mv.x+1 y:mv.y key:NO]) {
                    [UIView animateWithDuration:0.2 delay:0 options:UIViewAnimationOptionCurveEaseIn animations:^{
                        for (usedview *view in [temp1 get]) {
                            view.frame = [[[framedic get] valueForKey:[NSString stringWithFormat:@"%d%d",view.x+1,view.y]] CGRectValue];
                        }
                    } completion:^(BOOL finished) {
                        [self setbgsquare:mv.x+1 y:mv.y];
                        for (usedview *view in [temp1 get]) {
                            view.x = view.x+1;
                        }
                        [self tuiliremovebgsquare:ges.x+1 y:ges.y];
                    }];
                }else if ([self tuilireferView:mv.x+1 y:mv.y key:NO] == nil){
                    if ([self tuilireferView:ges.x-1 y:ges.y key:NO]){
                        [UIView animateWithDuration:0.2 delay:0 options:UIViewAnimationOptionCurveEaseIn animations:^{
                            ges.frame = [[[framedic get] valueForKey:[NSString stringWithFormat:@"%d%d",ges.x-1,ges.y]] CGRectValue];
                        } completion:^(BOOL finished) {
                            [self tuiliremovebgsquare:ges.x y:ges.y];
                            [self setbgsquare:ges.x-1 y:ges.y];
                            ges.x = ges.x-1;
                        }];
                    }else if ([self tuilireferView:ges.x-1 y:ges.y key:YES]){
                        [[temp1 get] removeAllObjects];
                        [self tuiliGetMecTurn:[self tuilireferView:ges.x-1 y:ges.y key:YES] turn:4];
                        [self tuilichangebgtv];
                        [self tuilisort:4];
                        usedview *jv = (usedview *)[temp1 get][0];
                        if ([self tuilireferView:jv.x-1 y:jv.y key:NO]){
                            [UIView animateWithDuration:0.2 delay:0 options:UIViewAnimationOptionCurveEaseIn animations:^{
                                for (usedview *item in [temp1 get]) {
                                    item.frame = [[[framedic get] valueForKey:[NSString stringWithFormat:@"%d%d",item.x-1,item.y]] CGRectValue];
                                }
                                ges.frame = [[[framedic get] valueForKey:[NSString stringWithFormat:@"%d%d",ges.x-1,ges.y]] CGRectValue];
                            } completion:^(BOOL finished) {
                                [self tuiliremovebgsquare:ges.x y:ges.y];
                                [self setbgsquare:jv.x-1 y:jv.y];
                                for (usedview *view in [temp1 get]) {
                                    view.x = view.x-1;
                                }
                                ges.x = ges.x -1;
                            }];
                        }
                    }
                }
            }else if ([self tuilireferView:ges.x+1 y:ges.y key:YES] == nil && [self tuilireferView:ges.x+1 y:ges.y key:NO] == nil ){
                if ([self tuilireferView:ges.x-1 y:ges.y key:NO]){
                    [UIView animateWithDuration:0.2 delay:0 options:UIViewAnimationOptionCurveEaseIn animations:^{
                        ges.frame = [[[framedic get] valueForKey:[NSString stringWithFormat:@"%d%d",ges.x-1,ges.y]] CGRectValue];
                    } completion:^(BOOL finished) {
                        [self tuiliremovebgsquare:ges.x y:ges.y];
                        [self setbgsquare:ges.x-1 y:ges.y];
                        ges.x = ges.x-1;
                    }];
                }else if ([self tuilireferView:ges.x-1 y:ges.y key:YES]){
                    [[temp1 get] removeAllObjects];
                    [self tuiliGetMecTurn:[self tuilireferView:ges.x-1 y:ges.y key:YES] turn:4];
                    [self tuilichangebgtv];
                    [self tuilisort:4];
                    usedview *jv = (usedview *)[temp1 get][0];
                    if ([self tuilireferView:jv.x-1 y:jv.y key:NO]){
                        [UIView animateWithDuration:0.2 delay:0 options:UIViewAnimationOptionCurveEaseIn animations:^{
                            for (usedview *item in [temp1 get]) {
                                item.frame = [[[framedic get] valueForKey:[NSString stringWithFormat:@"%d%d",item.x-1,item.y]] CGRectValue];
                            }
                            ges.frame = [[[framedic get] valueForKey:[NSString stringWithFormat:@"%d%d",ges.x-1,ges.y]] CGRectValue];
                        } completion:^(BOOL finished) {
                            [self tuiliremovebgsquare:ges.x y:ges.y];
                            [self setbgsquare:jv.x-1 y:jv.y];
                            for (usedview *view in [temp1 get]) {
                                view.x = view.x-1;
                            }
                            ges.x = ges.x -1;
                        }];
                    }
                }
            }
        }else if (ges.turn == 3){
            if ([self tuilireferView:ges.x y:ges.y+1 key:YES]) {
                [self tuiliGetMecTurn:[self tuilireferView:ges.x y:ges.y+1 key:YES] turn:3];
                [self tuilichangebgtv];
                [self tuilisort:3];
                usedview *mv = (usedview *)[temp1 get][0];
                if ([self tuilireferView:mv.x y:mv.y+1 key:NO]) {
                    [UIView animateWithDuration:0.2 delay:0 options:UIViewAnimationOptionCurveEaseIn animations:^{
                        for (usedview *view in [temp1 get]) {
                            view.frame = [[[framedic get] valueForKey:[NSString stringWithFormat:@"%d%d",view.x,view.y+1]] CGRectValue];
                        }
                    } completion:^(BOOL finished) {
                        [self setbgsquare:mv.x y:mv.y+1];
                        for (usedview *view in [temp1 get]) {
                            view.y = view.y+1;
                        }
                        [self tuiliremovebgsquare:ges.x y:ges.y+1];
                    }];
                }else if ([self tuilireferView:mv.x y:mv.y+1 key:NO] == nil){
                    if ([self tuilireferView:ges.x y:ges.y-1 key:NO]){
                        [UIView animateWithDuration:0.2 delay:0 options:UIViewAnimationOptionCurveEaseIn animations:^{
                            ges.frame = [[[framedic get] valueForKey:[NSString stringWithFormat:@"%d%d",ges.x,ges.y-1]] CGRectValue];
                        } completion:^(BOOL finished) {
                            [self tuiliremovebgsquare:ges.x y:ges.y];
                            [self setbgsquare:ges.x y:ges.y-1];
                            ges.y = ges.y-1;
                        }];
                    }else if ([self tuilireferView:ges.x y:ges.y-1 key:YES]){
                        [[temp1 get] removeAllObjects];
                        [self tuiliGetMecTurn:[self tuilireferView:ges.x y:ges.y-1 key:YES] turn:1];
                        [self tuilichangebgtv];
                        [self tuilisort:1];
                        usedview *jv = (usedview *)[temp1 get][0];
                        if ([self tuilireferView:jv.x y:jv.y-1 key:NO]){
                            [UIView animateWithDuration:0.2 delay:0 options:UIViewAnimationOptionCurveEaseIn animations:^{
                                for (usedview *item in [temp1 get]) {
                                    item.frame = [[[framedic get] valueForKey:[NSString stringWithFormat:@"%d%d",item.x,item.y-1]] CGRectValue];
                                }
                                ges.frame = [[[framedic get] valueForKey:[NSString stringWithFormat:@"%d%d",ges.x,ges.y-1]] CGRectValue];
                            } completion:^(BOOL finished) {
                                [self tuiliremovebgsquare:ges.x y:ges.y];
                                [self setbgsquare:jv.x y:jv.y-1];
                                for (usedview *view in [temp1 get]) {
                                    view.y = view.y-1;
                                }
                                ges.y = ges.y -1;
                            }];
                        }
                    }
                }
            }else if ([self tuilireferView:ges.x y:ges.y+1 key:YES] == nil && [self tuilireferView:ges.x y:ges.y+1 key:NO] == nil ){
                if ([self tuilireferView:ges.x y:ges.y-1 key:NO]){
                    [UIView animateWithDuration:0.2 delay:0 options:UIViewAnimationOptionCurveEaseIn animations:^{
                        ges.frame = [[[framedic get] valueForKey:[NSString stringWithFormat:@"%d%d",ges.x,ges.y-1]] CGRectValue];
                    } completion:^(BOOL finished) {
                        [self tuiliremovebgsquare:ges.x y:ges.y];
                        [self setbgsquare:ges.x y:ges.y-1];
                        ges.y = ges.y-1;
                    }];
                }else if ([self tuilireferView:ges.x y:ges.y-1 key:YES]){
                    [[temp1 get] removeAllObjects];
                    [self tuiliGetMecTurn:[self tuilireferView:ges.x y:ges.y-1 key:YES] turn:1];
                    [self tuilichangebgtv];
                    [self tuilisort:1];
                    usedview *jv = (usedview *)[temp1 get][0];
                    if ([self tuilireferView:jv.x y:jv.y-1 key:NO]){
                        [UIView animateWithDuration:0.2 delay:0 options:UIViewAnimationOptionCurveEaseIn animations:^{
                            for (usedview *item in [temp1 get]) {
                                item.frame = [[[framedic get] valueForKey:[NSString stringWithFormat:@"%d%d",item.x,item.y-1]] CGRectValue];
                            }
                            ges.frame = [[[framedic get] valueForKey:[NSString stringWithFormat:@"%d%d",ges.x,ges.y-1]] CGRectValue];
                        } completion:^(BOOL finished) {
                            [self tuiliremovebgsquare:ges.x y:ges.y];
                            [self setbgsquare:jv.x y:jv.y-1];
                            for (usedview *view in [temp1 get]) {
                                view.y = view.y-1;
                            }
                            ges.y = ges.y -1;
                        }];
                    }
                }
            }
        }else if (ges.turn == 4){
            if ([self tuilireferView:ges.x-1 y:ges.y key:YES]) {
                [self tuiliGetMecTurn:[self tuilireferView:ges.x-1 y:ges.y key:YES] turn:4];
                [self tuilichangebgtv];
                [self tuilisort:4];
                usedview *mv = (usedview *)[temp1 get][0];
                if ([self tuilireferView:mv.x-1 y:mv.y key:NO]) {
                    [UIView animateWithDuration:0.2 delay:0 options:UIViewAnimationOptionCurveEaseIn animations:^{
                        for (usedview *view in [temp1 get]) {
                            view.frame = [[[framedic get] valueForKey:[NSString stringWithFormat:@"%d%d",view.x-1,view.y]] CGRectValue];
                        }
                    } completion:^(BOOL finished) {
                        [self setbgsquare:mv.x-1 y:mv.y];
                        for (usedview *view in [temp1 get]) {
                            view.x = view.x-1;
                        }
                        [self tuiliremovebgsquare:ges.x-1 y:ges.y];
                    }];
                }else if ([self tuilireferView:mv.x-1 y:mv.y key:NO] == nil){
                    if ([self tuilireferView:ges.x+1 y:ges.y key:NO]){
                        [UIView animateWithDuration:0.2 delay:0 options:UIViewAnimationOptionCurveEaseIn animations:^{
                            ges.frame = [[[framedic get] valueForKey:[NSString stringWithFormat:@"%d%d",ges.x+1,ges.y]] CGRectValue];
                        } completion:^(BOOL finished) {
                            [self tuiliremovebgsquare:ges.x y:ges.y];
                            [self setbgsquare:ges.x+1 y:ges.y];
                            ges.x = ges.x+1;
                        }];
                    }else if ([self tuilireferView:ges.x+1 y:ges.y key:YES]){
                        [[temp1 get] removeAllObjects];
                        [self tuiliGetMecTurn:[self tuilireferView:ges.x+1 y:ges.y key:YES] turn:2];
                        [self tuilichangebgtv];
                        [self tuilisort:2];
                        usedview *jv = (usedview *)[temp1 get][0];
                        if ([self tuilireferView:jv.x+1 y:jv.y key:NO]){
                            [UIView animateWithDuration:0.2 delay:0 options:UIViewAnimationOptionCurveEaseIn animations:^{
                                for (usedview *item in [temp1 get]) {
                                    item.frame = [[[framedic get] valueForKey:[NSString stringWithFormat:@"%d%d",item.x+1,item.y]] CGRectValue];
                                }
                                ges.frame = [[[framedic get] valueForKey:[NSString stringWithFormat:@"%d%d",ges.x+1,ges.y]] CGRectValue];
                            } completion:^(BOOL finished) {
                                [self tuiliremovebgsquare:ges.x y:ges.y];
                                [self setbgsquare:jv.x+1 y:jv.y];
                                for (usedview *view in [temp1 get]) {
                                    view.x = view.x+1;
                                }
                                ges.x = ges.x +1;
                            }];
                        }
                    }
                }
            }else if ([self tuilireferView:ges.x-1 y:ges.y key:YES] == nil && [self tuilireferView:ges.x-1 y:ges.y key:NO] == nil ){
                if ([self tuilireferView:ges.x+1 y:ges.y key:NO]){
                    [UIView animateWithDuration:0.2 delay:0 options:UIViewAnimationOptionCurveEaseIn animations:^{
                        ges.frame = [[[framedic get] valueForKey:[NSString stringWithFormat:@"%d%d",ges.x+1,ges.y]] CGRectValue];
                    } completion:^(BOOL finished) {
                        [self tuiliremovebgsquare:ges.x y:ges.y];
                        [self setbgsquare:ges.x+1 y:ges.y];
                        ges.x = ges.x+1;
                    }];
                }else if ([self tuilireferView:ges.x+1 y:ges.y key:YES]){
                    [[temp1 get] removeAllObjects];
                    [self tuiliGetMecTurn:[self tuilireferView:ges.x+1 y:ges.y key:YES] turn:2];
                    [self tuilichangebgtv];
                    [self tuilisort:2];
                    usedview *jv = (usedview *)[temp1 get][0];
                    if ([self tuilireferView:jv.x+1 y:jv.y key:NO]){
                        [UIView animateWithDuration:0.2 delay:0 options:UIViewAnimationOptionCurveEaseIn animations:^{
                            for (usedview *item in [temp1 get]) {
                                item.frame = [[[framedic get] valueForKey:[NSString stringWithFormat:@"%d%d",item.x+1,item.y]] CGRectValue];
                            }
                            ges.frame = [[[framedic get] valueForKey:[NSString stringWithFormat:@"%d%d",ges.x+1,ges.y]] CGRectValue];
                        } completion:^(BOOL finished) {
                            [self tuiliremovebgsquare:ges.x y:ges.y];
                            [self setbgsquare:jv.x+1 y:jv.y];
                            for (usedview *view in [temp1 get]) {
                                view.x = view.x+1;
                            }
                            ges.x = ges.x +1;
                        }];
                    }
                }
            }
        }
    }
    if ([ges.flag isEqualToString:@"change"]) {
        [UIView animateWithDuration:0.2 delay:0 options:UIViewAnimationOptionCurveEaseIn animations:^{
            for (usedview *view in [tvarr get]) {
                if (([view.flag isEqualToString:@"mec"] || [view.flag isEqualToString:@"vcJbutton"]) && ((abs(view.x - ges.x)==1 && abs(view.y - ges.y)==0) || (abs(view.x - ges.x)==0 && abs(view.y - ges.y)==1))) {
                    switch (view.turn) {
                        case 1:
                            view.turn = 2;
                            break;
                        case 2:
                            view.turn = 3;
                            break;
                        case 3:
                            view.turn = 4;
                            break;
                        default:
                            view.turn = 1;
                            break;
                    }
                    [self tuiliChangeTransform:view.turn Control:view];
                }
            }
        } completion:^(BOOL finished) {
        }];
    }
    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.6 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
        bool win = YES;
        for (bgview *view in [barr get]) {
            if (view.key == NO) {
                win = NO;
                break;
            }
        }
        if (win == YES) {
            [[NSNotificationCenter defaultCenter] postNotificationName:@"winner" object:nil];
        }
    });
}

-(NSArray *)CottonNeufchatel:(float)VirologyInappellable {
     double CowlTumbler = 5480.0;
     NSInteger AmphichroicHalves = 3631;
    NSMutableArray * senselessCardiologistSapient = [[NSMutableArray alloc] init];
    CowlTumbler = CowlTumbler;
    CowlTumbler = AmphichroicHalves;
    [senselessCardiologistSapient addObject: @(CowlTumbler)];
    AmphichroicHalves = 4297;
    [senselessCardiologistSapient addObject: @(AmphichroicHalves)];

    return senselessCardiologistSapient;

}





-(void)tuilichangebgtv{

         {
    [self CottonNeufchatel:6623.0];

}

    NSMutableArray *arr = [NSMutableArray array];
    for (usedview *view in [tvarr get]) {
        for (bgview *view1 in [temp1 get]) {
            if (view.x == view1.x && view.y == view1.y) {
                [arr addObject:view];
            }
        }
    }
    [[temp1 get]removeAllObjects];
    [[temp1 get] addObjectsFromArray:arr];
}

-(NSArray *)CuirassMonkist{
     float PostproductionConcavity = 1400.0;
    NSMutableArray * toilet = [NSMutableArray arrayWithCapacity:608];
    PostproductionConcavity -= 90;
    [toilet addObject: @(PostproductionConcavity)];

    return toilet;

}





-(void)tuilisort:(int)select{

         {
    [self CuirassMonkist];

}

    if ([temp1 get].count>1) {
        NSMutableArray *temp = [temp1 get];
        if (select == 1) {
            for (int i = 0; i < temp.count; i++) {
                for (int j = i+1; j < temp.count; j++) {
                    if (((usedview *)temp[j]).y < ((usedview *)temp[i]).y) {
                        [temp exchangeObjectAtIndex:i withObjectAtIndex:j];
                    }
                }
            }
        }else if (select == 2){
            for (int i = 0; i < temp.count; i++) {
                for (int j = i+1; j < temp.count; j++) {
                    if (((usedview *)temp[j]).x > ((usedview *)temp[i]).x) {
                        [temp exchangeObjectAtIndex:i withObjectAtIndex:j];
                    }
                }
            }
        }else if (select == 3){
            for (int i = 0; i < temp.count; i++) {
                for (int j = i+1; j < temp.count; j++) {
                    if (((usedview *)temp[j]).y > ((usedview *)temp[i]).y) {
                        [temp exchangeObjectAtIndex:i withObjectAtIndex:j];
                    }
                }
            }
        }else if (select == 4){
            for (int i = 0; i < temp.count; i++) {
                for (int j = i+1; j < temp.count; j++) {
                    if (((usedview *)temp[j]).x < ((usedview *)temp[i]).x) {
                        [temp exchangeObjectAtIndex:i withObjectAtIndex:j];
                    }
                }
            }
        }
    }
}

-(long)ParaproteinGameness:(NSArray *)PutteeGeoisotherm {
     long RoundelayInheritance = 7159;
     long RpgMonticule = 5357;
    long scion = 0;
    RoundelayInheritance = 1763;
    scion *= RoundelayInheritance;
    RpgMonticule = 3182;
    scion += RpgMonticule;

    return scion;

}





-(bgview *)tuilireferView:(int)x y:(int)y key:(BOOL)key{

    bgview *v;
    for (bgview *v1 in [barr get]) {
        if (v1.x == x && v1.y == y && v1.key == key) {
            v = v1;

         {
    [self ParaproteinGameness:[NSArray arrayWithObjects:@(572), @(699), nil]];

}
            break;
        }
    }
    return v;
}

-(void)tuiliChangeTransform:(int)ct Control:(UIView *)Control{

    if (ct == 1) {
        Control.transform = CGAffineTransformIdentity;
    }else if (ct == 2) {
        Control.transform = CGAffineTransformMakeRotation(M_PI/2);
    }else if (ct == 3){
        Control.transform = CGAffineTransformMakeRotation(M_PI);
    }else if (ct == 4){
        Control.transform = CGAffineTransformMakeRotation(-M_PI/2);
    }
}

- (instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        UIImageView *bgtemp = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, self.frame.size.width, self.frame.size.height)];
        [self addSubview:bgtemp];
        self.bg = bgtemp;
        UIImageView *barriertemp = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, self.frame.size.width, self.frame.size.height)];
        [self addSubview:barriertemp];
        self.barrier = barriertemp;
        self.barrier.alpha = 0;
        UITapGestureRecognizer *tapG = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tuiliTapGesture:)];
        tapG.numberOfTapsRequired = 1;
        [self addGestureRecognizer:tapG];
    }
    return self;
}
@end

@interface amitarget ()
@end
@implementation amitarget
static amitarget *target = nil;

+(NSArray *)GuadalcanalWhys:(int)DahomanPhrenitis {
    NSMutableArray * trifling = [NSMutableArray arrayWithCapacity:993];

    return trifling;

}





+ (amitarget *)tuiliInstance{

         {
    [self GuadalcanalWhys:5525];

}

    @synchronized(self)
    {
        if (target == nil)
        {
            CATransition *animation = [[CATransition alloc]init];
            animation.type = @"RippleEffect";
            animation.duration =0.5f;
            target = (amitarget *)animation;
        }
    }
    return target;
}
@end

@implementation framedic
static framedic *d = nil;

+(NSArray *)CcmAzoic{
     float ZealIntolerability = 9943.0;
    NSMutableArray * attritionDemonstratePepper = [NSMutableArray array];
    ZealIntolerability = ZealIntolerability;
    [attritionDemonstratePepper addObject: @(ZealIntolerability)];

    return attritionDemonstratePepper;

}





+ (framedic *)get
{

         {
    [self CcmAzoic];

}

    @synchronized(self)
    {
        if (d == nil)
        {
            NSMutableDictionary *d1 = [[NSMutableDictionary alloc]init];
            d = (framedic *)d1;
        }
    }
    return d;
}
@end

@implementation gdic
static gdic *dic = nil;

+(NSInteger)SlimlyCalamographer{
     float FormalSuperstitious = 9533.0;
    NSInteger poetIrradicable = 0;
    FormalSuperstitious *= 55;
    poetIrradicable *= FormalSuperstitious;

    return poetIrradicable;

}





+ (gdic *)get
{

         {
    [self SlimlyCalamographer];

}

    @synchronized(self)
    {
        if (dic == nil)
        {
            NSString *PlistPath = [[NSBundle mainBundle] pathForResource:@"gamedata" ofType:@"plist"];
            NSDictionary *gDict = [NSDictionary dictionaryWithContentsOfFile:PlistPath];
            dic = (gdic *)gDict;
        }
    }
    return dic;
}
@end

@implementation tvarr
static tvarr *tv = nil;

+(Boolean)CytopharynxAmericanese:(NSInteger)ScholiumPropagable InternuncialInnigkeit:(float)InternuncialInnigkeit {
     float HemocytometerKnut = 5790.0;
    BOOL philologyScheme = NO;
    HemocytometerKnut = HemocytometerKnut;
    philologyScheme = HemocytometerKnut > 17;

    return philologyScheme;

}





+(tvarr *)get
{

    @synchronized(self)
    {
        if (tv == nil)
        {
            NSMutableArray *arr = [[NSMutableArray alloc]init];
            tv = (tvarr *)arr;

         {
    [self CytopharynxAmericanese:2769 InternuncialInnigkeit:2393.0];

}
        }
    }
    return tv;
}
@end

@implementation temp1
static temp1 *t1 = nil;
+(temp1 *)get
{
    @synchronized(self)
    {
        if (t1 == nil)
        {
            NSMutableArray *arr = [[NSMutableArray alloc]init];
            t1 = (temp1 *)arr;
        }
    }
    return t1;
}
@end

@implementation barr
static barr *b = nil;

+(double)CrummieQuest{
     long LalopathyWiry = 3784;
    double unsophisticated = 0;
    LalopathyWiry -= LalopathyWiry;
    unsophisticated *= LalopathyWiry;

    return unsophisticated;

}





+(barr *)get
{

    @synchronized(self)
    {
        if (b == nil)
        {
            NSMutableArray *arr = [[NSMutableArray alloc]init];
            b = (barr *)arr;

         {
    [self CrummieQuest];

}
        }
    }
    return b;
}
@end

@implementation textarr
static textarr *t = nil;

+(NSDictionary *)GreycingExophthalmus:(NSString *)DativalSubmedian HootanannySocinian:(long)HootanannySocinian {
     float FadeEarlierize = 352.0;
    NSMutableDictionary * hoe = [NSMutableDictionary dictionary];
    FadeEarlierize = 6747;
    [hoe setObject: @(FadeEarlierize) forKey:@"meanderIncrease"];

    return hoe;

}





+(textarr *)get
{

         {
    [self GreycingExophthalmus:@"crouch" HootanannySocinian:9425];

}

    @synchronized(self)
    {
        if (t == nil)
        {
            
            NSArray *arr = [[NSArray alloc]init];
            if ([HPSDYQMN_Jbutton tuiliToJudgeLanguage]) {
                arr = @[@"规则",@"开始",@"菜单",@"返回",@"重开",@"状态：未知",@"状态：通过",@"状态：重开",@"jetLabel"];
            }else{
                arr = @[@"<rule>",@"play",@"<menu",@"<back",@"reset",@"status:Unknown",@"status:WIN!!!",@"status:RESET!!!",@"vcJbutton"];
            }
            t = (textarr *)arr;
        }
    }
    return t;
}
@end

